#!/bin/sh
#--------------------------------------------------
# We backup the database with RMAN and using nocatalog 
# So we must Record the DBID must first
#
# set DBID=1972435038
# The backup RETENTION POLICY TO REDUNDANCY 1
# The CONTROLFILE AUTOBACKUP ON
#--------------------------------------------------
PATH=$PATH:/home/oracle/scripts ; export PATH
STATUS_DIR=/oracle/backup/BK_STATUS
BK_STATUS=/oracle/backup/log/BK_STATUS
MSG_LOG=/oracle/backup/log/joblog_`date +%Y%m`.log ;export MSG_LOG
JOBNAME=Rman_Backup          ; export JOBNAME

ORACLE_SID=PROD; export ORACLE_SID
ORACLE_BASE=/oracle/app/oracle ;export ORACLE_BASE
ORACLE_HOME=/oracle/app/oracle/product/10.2.0/db_1; export ORACLE_HOME

PATH=$PATH:$ORACLE_HOME:$ORACLE_HOME/bin; export PATH
Date_Num=`date +%u`

MSG_JOB S

if [[ Date_Num -eq 6 ]] then
  rman cmdfile=/home/oracle/scripts/Fullback.rman log=/home/oracle/scripts/rmanlog_`date +%Y%m%d`.log
  if [[ $? -eq 0 ]] then
    MSG_JOB I 'Full Backup Finish'
  else
    MSG_JOB I 'Full Backup Error'
  fi 
else
  rman cmdfile=/home/oracle/scripts/Incrback.rman log=/home/oracle/scripts/rmanlog_`date +%Y%m%d`.log
  if [[ $? -eq 0 ]] then
    MSG_JOB I 'Incremental Backup Finish'
  else
    MSG_JOB I 'Incremental Backup Error'
  fi
fi
MSG_JOB N
